<template>
  <div class="boy">
    <h3>男人组件</h3>
    <div>金钱：{{ money }}</div>
    <button @click="add">搬砖+1</button>
    <button @click="addFn">卖肾+100</button>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  // 计算属性
  computed: {
    money() {
      return this.$store.state.money;
    },
  },
  //   methods: {
  //     add() {
  //       this.$store.commit("add");
  //     },
  // addFn() {
  //   this.$store.commit("addFn", 1000);
  // },
  //   },
  methods: {
    ...mapMutations(["add"]),
    addFn() {
      this.$store.commit("addFn", 1000);
    },
  },

  methods: {
    ...mapMutations(["add"]),
    addFn() {
      this.$store.commit("addFn", 1000);
    },
  },
};
</script>

<style>
button {
  padding: 5px;
  line-height: 30px;
  margin-left: 10px;
}
</style>
